package Thread;

class MyRunnable implements Runnable {

    @Override
    public void run() {
        while (true){
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("hello t");
        }
    }
    }
public class ThreadDemo2 {
    //第二种方法是使用Runnable interface(接口) 来描述线程入口
    public static void main(String[] args) {
        MyRunnable myRunnable = new MyRunnable();
        Thread t = new Thread(myRunnable);
        t.start();
        while (true) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("hello main");
        }
    }
}
